<!DOCTYPE html>
<!--
Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/model/event_set.html">
<link rel="import" href="/tracing/model/model.html">
<link rel="import" href="/tracing/model/power_series.html">
<link rel="import" href="/tracing/ui/analysis/multi_power_sample_sub_view.html">

<script>
'use strict';

tr.b.unittest.testSuite(function() {
  test('instantiate_noSamplesOrVSyncs', function() {
    const viewEl = document.createElement(
        'tr-ui-a-multi-power-sample-sub-view');
    viewEl.selection = undefined;
    this.addHTMLOutput(viewEl);
  });

  test('instantiate_noVSyncs', function() {
    const model = new tr.Model();
    const series = new tr.model.PowerSeries(model.device);

    model.device.vSyncTimestamps = [];
    series.addPowerSample(1, 1);
    series.addPowerSample(2, 2);
    series.addPowerSample(3, 3);
    series.addPowerSample(4, 2);

    const view = document.createElement('tr-ui-a-multi-power-sample-sub-view');
    const eventSet = new tr.model.EventSet(series.samples);
    view.selection = eventSet;

    this.addHTMLOutput(view);

    assert.deepEqual(view.$.chart.samples, eventSet);
    assert.sameDeepMembers(view.$.chart.vSyncTimestamps, []);
  });

  test('instantiate', function() {
    const model = new tr.Model();
    const series = new tr.model.PowerSeries(model.device);

    model.device.vSyncTimestamps = [0];
    series.addPowerSample(1, 1);
    series.addPowerSample(2, 2);
    series.addPowerSample(3, 3);
    series.addPowerSample(4, 2);

    const view = document.createElement('tr-ui-a-multi-power-sample-sub-view');
    const eventSet = new tr.model.EventSet(series.samples);
    view.selection = eventSet;

    this.addHTMLOutput(view);

    assert.deepEqual(view.$.chart.samples, eventSet);
    assert.sameDeepMembers(view.$.chart.vSyncTimestamps, [0]);
  });
});
</script>
